package com.liuwang.meal.service;

import com.liuwang.meal.R;
import com.liuwang.meal.ui.LodingActivity;
import com.liuwang.meal.util.MyUtil;
import com.liuwang.meal.util.SocketUtil;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

/**
 * @author 陈江根
 * 
 */
public class SocketServer extends Service {

	private SocketUtil client;

	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		client.closeSocket();
	}

	@Override
	public void onStart(Intent intent, int startId) {
		super.onStart(intent, startId);
		
		// TODO 资源数据更新
//		try {
//			if (null == client) {
//				client = new SocketUtil("192.168.1.107", 8898);
//			}
//		} catch (Exception e) {
//			Toast.makeText(this, "服务器连接失败,请检查服务器是否开启...", 0).show();
//		}
//		Log.i("test",client.sendMsg("0,login,[{account:account,password:password,table_no:table_no,customer_count:customer_count,machine_code:machine_code}]"));
//		
//		Intent it = new Intent("com.liuwang.sendMsg_lodingActivity");
//		it.putExtra("msg", "hi,我通过广播发送消息了");
//		sendBroadcast(it);
		
//		new Thread(new Runnable() {
//			@Override
//			public void run() {
//				Log.i("test",
//						"返回的消息："
//								+ client.sendMsg("0,login,[{account:account,password:password,table_no:table_no,customer_count:customer_count,machine_code:machine_code}]"));// /
//			}
//		}).start();
	}

}
